package edu.zju.gis.cky.entity;

import lombok.Data;

/**
 * @author Zhou Yuquan
 * @version 1.0, 2021-12-10
 */
@Data
public class Result<T>{

    private T data;
    private int code;
    private String message;

    public static<T> Result<T> success() {
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMessage("Success");
        return result;
    }

    public static<T> Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.setData(data);
        result.setCode(200);
        result.setMessage("Success");
        return result;
    }

    public static<T> Result<T> failure() {
        Result<T> result = new Result<>();
        result.setCode(-1);
        return result;
    }

    public static<T> Result<T> failure(String message) {
        Result<T> result = new Result<>();
        result.setCode(-1);
        result.setMessage(message);
        return result;
    }
}
